package com.study.lease.common.utils;

import java.util.Random;

/**
 * 验证码工具类
 * 作用：验证码生成
 */
public class CodeUtil {
    public static String getCode(Integer length){
        StringBuilder builder = new StringBuilder();// 创建一个可变字符串
        Random random = new Random();
        for (int i = 0; i < length; i++){
            int num = random.nextInt(10);// [0,10)]
            builder.append(num);// 追加数字
        }
        return builder.toString();// 返回字符串
    }
}
